package com.fudan.run.ctx;

import java.util.HashMap;
import java.util.Map;

import com.fudan.cfg.base.ActionDef;
import com.fudan.run.action.ActionHandler;

public class ActionContext extends EnvContext<ActionDef, ActionHandler<? extends ActionDef>>{

	private Map<String,Class<? extends ActionDef>> actionCfgMap;
	private Map<String,Class<? extends ActionHandler<? extends ActionDef>>> actionHandlerMap;

	public ActionContext() {
		this.actionCfgMap = new HashMap<>();
		this.actionHandlerMap = new HashMap<>();
	}

	@Override
	public void addParser(String name, Class<? extends ActionDef> cfgParserClz) {
		this.actionCfgMap.put(name, cfgParserClz);
	}

	@Override
	public void addHandler(String name, Class<? extends ActionHandler<? extends ActionDef>> handlerClz) {
		this.actionHandlerMap.put(name, handlerClz);
	}

	@Override
	public Class<? extends ActionDef> getParser(String name) {
		return this.actionCfgMap.get(name);
	}

	@Override
	public Class<? extends ActionHandler<? extends ActionDef>> getHandler(String name) {
		return this.actionHandlerMap.get(name);
	}

}
